require 'functest'

class PersonTestCase < Test::Unit::TestCase
  
  def test_01_Login
    @@application = Application.new
    @@browser = @@application.browser
    
    @@application.goLogin
    @@application.doLogin "chris", "password"
  end
  
  def test_02_AddPerson
    @@browser.link(:text, "People").click
    assert(@@browser.contains_text("From Date"))
    @@browser.button(:name, "addPerson").click
    assert(@@browser.contains_text("Add Person"))
  end
  
  def test_03_EnterBasicInfo
    @@browser.select_list(:name, "title").select("Mr")
    @@browser.text_field(:name, "firstName").set("Joe")
    @@browser.text_field(:name, "middleName").set("Paul")
    @@browser.text_field(:name, "surname").set("Dimagio")
    @@browser.text_field(:name, "dateOfBirth").set("01/12/1970")
    @@browser.select_list(:name, "personType").select("Partner")
    @@browser.radio(:value, "MALE").set
    @@browser.select_list(:name, "maritalStatus").select("Single")
    @@browser.button(:value, "Save").click
    
    assert(@@browser.contains_text("From Date"))
  end
  
  def test_04_SearchForNewPerson
    @@browser.text_field(:name, "surname").set("Dimagio")
    @@browser.button(:value, "Find").click
    assert(@@browser.contains_text("Results 1"))
    assert(@@browser.contains_text("Dimagio"))
  end
  
  def test_99_Close
    @@application.doLogoffAndCloseBrowser
  end
  
end
